package com.verisette.ncos.service.datasupport.gateway;

import java.util.ArrayList;
import java.util.List;

import org.corp.agi.common.bean.LabelValueBean;
import org.corp.agi.common.bean.PagingBean;
import org.corp.agi.persistence.dao.CommonDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;


import com.verisette.ncos.persistence.domain.MasterUserGroup;
import com.verisette.ncos.persistence.domain.MasterUserProfile;

@Transactional
public class NcosSupportServiceImpl implements NcosSupportService {
	
	private CommonDAO commonDAO;
	@Autowired
	@Required
	public void setCommonDAO(@Qualifier("commonDAO")CommonDAO commonDAO) {
		this.commonDAO = commonDAO;
	}

	public List<LabelValueBean> getAllRoles (){
		List<LabelValueBean> result = new ArrayList<LabelValueBean>();
		
		PagingBean pagingBean = new PagingBean();
		pagingBean.setRowsPerPage(Integer.MAX_VALUE);
		pagingBean.setOrderBy("usgName");
		
		List<MasterUserGroup> lists =  (List<MasterUserGroup>) commonDAO.findAll(MasterUserGroup.class, pagingBean);
		if(lists!=null){
			for(MasterUserGroup o:lists){
				result.add(new LabelValueBean(o.getUsgName(),String.valueOf(o.getUsgId())));
			}
		}
		return result;
	}

	public List<LabelValueBean> getAllUserName(){
		List<LabelValueBean> result = new ArrayList<LabelValueBean>();
		
		PagingBean pagingBean = new PagingBean();
		pagingBean.setRowsPerPage(Integer.MAX_VALUE);
		pagingBean.setOrderBy("uspUserName");
		
		List<MasterUserProfile> lists =  (List<MasterUserProfile>) commonDAO.findAll(MasterUserProfile.class, pagingBean);
		if(lists!=null){
			for(MasterUserProfile o:lists){
				result.add(new LabelValueBean(o.getUspUserName(),o.getUspId().toString()));
			}
		}
		return result;
		
	}

}
